use axum::Json;
use http::HeaderMap;
use serde_json::Value;
use sea_orm::EntityTrait;
use crate::query;

use super::del_user::{one_str, many_str};

// 单个 = 用户删除自己创建的数据
pub async fn by_id<E:EntityTrait>(header: HeaderMap, entity:E, id:&str) -> Result<Json<Value>, Json<Value>>{ one_str(header, entity, id, "id").await}
// 删除多个 = 用户删除自己创建的数据
pub async fn by_ids<E:EntityTrait>(header: HeaderMap, entity:E, id:&str) -> Result<Json<Value>, Json<Value>>{
    let ids = query::utils::vec_str_str_(&id, "必选参数")?;
    if ids.len() == 1 {
        let id = &ids[0];
        by_id(header, entity, &id).await
    }else{
        many_str(header, entity, "id", ids).await
    }
}